using System;
using RollManager.Forms.MainPanels;
using RollManager.Library;

namespace RollManager.Forms.MenuDialogs
{
    public partial class CopyActionDialog : MenuDialog
    {
        private RollManager.Library.Action m_Action;

        private DevLevel DevLevel
        {
            get
            {
                return (DevLevel) devLevelList.SelectedItem;
            }
        }

        public CopyActionDialog( AdminActionsPanel panel, RollManager.Library.Action action )
            : base( panel )
        {
            m_Action = action;
            InitializeComponent();

            nameBox.Text = m_Action.Name;

            devLevelList.DisplayMember = ItemBase.NAME_PROPERTY;
            devLevelList.DataSource = Database.GetDevLevels();
        }

        private void okButton_Click( object sender, EventArgs e )
        {
            Database.CopyAction( m_Action.Id, nameBox.Text, DevLevel.Id );
            CloseAndRefresh();
        }

        private void cancelButton_Click( object sender, EventArgs e )
        {
            Close();
        }
    }
}